//封装一个函数:获取一个结果:当前早上|上午|下午|晚上
export const getTime = () => {
  let message = ''
  //通过内置构造函数Date
  const hours = new Date().getHours()
  //情况的判断
  if (hours <= 9) {
    message = '早上'
  } else if (hours <= 12) {
    message = '上午'
  } else if (hours <= 18) {
    message = '下午'
  } else {
    message = '晚上'
  }
  return message
}

export const formatTime = (date) => {
  return date[0] + '年' + date[1] + '月' + date[2] + '日' + date[3] + '时'
}

// 格式化时间戳
export const formatTimeStamp = (timestamp) => {
  const date = new Date(timestamp)
  const year = date.getFullYear()
  const month = date.getMonth() + 1
  const day = date.getDate()
  const hour = date.getHours()
  const minute = date.getMinutes()
  const second = date.getSeconds()
  return (
    year + '-' + month + '-' + day + '' + hour + ':' + minute + ':' + second
  )
}

export const getSeat = (seat) => {
  let message = ''
  const row = Math.floor(seat / 6) + 1
  const col = seat % 6
  if (col == 0 || col == 6) {
    message = row - 1 + '排' + '6座'
    return message
  }
  message = row + '排' + col + '座'
  return message
}
